package com.echo.week;

/**
 * @Author echo
 * @Description
 * @Date 2023/10/16.
 * @Version 1.0
 */
public class DemoJMM {
    public static void main(String[] args) throws InterruptedException {

        RunDemo runDemo = new RunDemo();
        Thread thread = new Thread(runDemo);
        thread.start();

        Thread.sleep(1000);

        runDemo.flag = false;
        System.out.println("将flag修改为："+ false);
    }
    static class RunDemo implements Runnable {
        public boolean  flag = true;
        @Override
        public void run() {
            while (flag){
//                System.out.println(flag);
            }
            System.out.println("flag为false，执行结束---");
        }
    }
}
